{extend name='table'}

{block name="button"}
<!--{if auth("add")}-->
<button data-modal='{:url("add")}' data-table-id="MenuTable" class='layui-btn layui-btn-sm layui-btn-primary'>{:lang('添加经销商')}</button>
<!--{/if}-->
{/block}

{block name="content"}
<div class="think-box-shadow">
    {include file='jxs/index_search'}
    <table id="OplogTable" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>
{/block}

{block name='script'}
<script>
    $(function () {
        $('#OplogTable').layTable({
            even: true, height: 'full',
            sort: {field: 'id', type: 'desc'},
            cols: [[
                {checkbox: true},
                {field: 'id', title: '序号', width: 70, sort: true, align: 'center'},
                {field: 'user_code', title: '{:lang("经销商编号")}'},
                {field: 'parent_name', title: '{:lang("上级账号")}'},
                {field: 'username', title: '{:lang("账号")}'},
                {field: 'nickname', title: '{:lang("账号名称")}'},
                // {field: 'password', title: '{:lang("账号密码")}'},
                {field: 'role_name', title: '{:lang("角色")}'},
                {field: 'province', title: '{:lang("省份")}'},
                {field: 'city', title: '{:lang("城市")}'},
                {field: 'district', title: '{:lang("区县")}'},
                {field: 'jxs_integral', title: '{:lang("积分")}'},
                // {field: 'detail', title: '{:lang("详情地址")}'},
                // {field: 'login_time', title: '{:lang("最新登录时间")}'},
                // {field: 'add_time', title: '{:lang("创建时间")}'},
                {toolbar: '#toolbar', title: '{:lang("操作面板")}',width: 480, align: 'left',fixed: 'right'}
            ]]
        });
        
    });
    function  ajaxareas(obj){
        console.log("dianwo")
        var pagesaaa=JSON.parse(window.sessionStorage.getItem("pages"));
        window.sessionStorage.setItem("pages2",JSON.stringify(pagesaaa));
        pagesaaa.OplogTable=1;
        window.sessionStorage.setItem("pages",JSON.stringify(pagesaaa));
        window.location.href=$(obj).data("rrhref")
    }
</script>
<!-- 操控面板的模板 -->
<script type="text/html" id="toolbar">
   
    <a class="layui-btn layui-btn-sm" data-title="销售范围" 
     data-rrhref='admin.html#{:url("xsarea/index")}?spm=m-12-22&id={{d.user_code}}' onclick="ajaxareas(this)"  >{:lang('销售范围')}</a>
    
    
    {if auth('jxsintegral')}
    <a class="layui-btn layui-btn-sm"  data-title="积分管理" data-modal='{:url("jxsintegral")}?id={{d.id}}'  >{:lang('积分管理')}</a>
    {/if}
    
    {if auth('reloadpass')}
    <a class="layui-btn layui-btn-sm"  data-confirm="确定要重置密码吗？" data-action="{:url('reloadpass')}" data-value="id#{{d.id}}"    >{:lang('重置密码')}</a>
    {/if}

    {if auth('edit')}
    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="编辑账号" data-modal='{:url("edit")}?id={{d.id}}'>{:lang('编 辑')}</a>
    {/if}
    {if auth('add')}
        {{# if( d.role != 4 ) { }}
            <button data-modal='{:url("add")}?pid={{d.id}}' data-table-id="MenuTable" 
             class='layui-btn layui-btn-sm layui-btn-normal'>
             {:lang('添加下级')}
             </button>
             
        {{# } }}
    {/if}
    {if auth('remove')}
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除账号吗？" data-action="{:url('remove')}" data-value="id#{{d.id}}"  >删 除</a>
    {/if}

</script>
{/block}